<?php
/********************************************************
 *
 * 此文件的作用:
 *		文章表的入口
 *
 * @copyright Copyright (c) 2008-2009
 * @author 刘昌功 lcg635@126.com
 *
 ********************************************************/
defined('APP_DIR') or die('404 Not Found');

FLEA::loadClass('Common_Table');

class Table_News extends Common_Table {
    var $tableName = 'news';
    var $primaryKey = 'news_id';

	function form($type, $data = null) {
		$this->_ui = FLEA::initWebControls();
		$form = array(
			'news_id' => $this->_ui->control('Hidden', 'news_id',
				array(
					'value' => $data['news_id']
				),
				true
			),
			'title' => $this->_ui->control('Textbox', 'title',
				array(
					'value' => $data['title'],
					'required' => 'true',
					'check' => 'notBlank',
					'size' => 98,
					'showName' => '新闻标题'
				),
				true
			),
			'author' => $this->_ui->control('DropdownList', 'author',
				array(
					'required' => 'true',
					'selected' => 0,
					'items' => array(
						'勤工助学管理委员会' => 0
					),
					'showName' => '作者'
				),
				true
			),
			'content' => $this->_ui->control('Fckeditor', 'content',
				array(
					'required' => 'true',
					'Value' => $data['content'],
					'showName' => '新闻内容'
				),
				true
			),
			'finish' => $this->_ui->control('Textbox', 'finish',
				array(
					'check' => 'isDate(\'YYYY-MM-DD\');',
					'value' => date('Y-m-d', time()+3600*24*7),
					'showName' => '有效日期'
				),
				true
			),
			'type' => $this->_ui->control('DropdownList', 'type',
				array(
					'required' => 'true',
					'selected' => empty($data['type']) ? -1 : $data['type'],
					'items' => array(
						'新闻' => 0,
						'家教' => 1
					),
					'showName' => '文章类型'
				),
				true
			),
			'important' => $this->_ui->control('Checkbox', 'important',
				array(
					'value' => 1,
					'checked' => $data['important']
				),
				true
			)
		);
		return $form;
	}
}
